|
|
|
|
|
|
|
You can also initialize a string to a sequence of spaces using the Space$ function. |
|
|
|
 |
|
|
|
|
Dim txt As String
txt = Space$(256) |
|
|
|
|
|
|
|
|
All of these methods create a 256-character string that you can pass into an API routine. |
|
|
|
|
|
|
|
|
You can pass a single element in an array just as you would pass any other single item. For example, the following code uses the MoveTo and LineTo API functions to connect the points with coordinates stored in the ptx and pty arrays. |
|
|
|
 |
|
|
|
|
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function MoveToEx Lib "gdi32" _
Alias "MoveToEx" (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) _
As Long
Private Declare Function LineTo Lib "gdi32" _
Alias "LineTo" (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long) As Long
Private ptx(0 to 10) As Long
Private pty(0 to 10) As Long
' (Initialize the arrays, etc.)
: Sub DrawLines()
Dim pt As POINTAPI
Dim i As Integer
MoveToEx hDC, ptx(0), pty(0), pt
For i = 1 To 10
LineTo hDC, ptx(i), pty(i)
Next i
End Sub |
|
|
|
|
|
|
|
|
The values ptx(i) and pty(i) are passed into the LineTo routine just like any other long integers. |
|
|
|
|
|
|
|
|
Many API functions expect the address of an array as a parameter. Because the first element in an array is at the beginning, you can pass the address of an entire array by passing the address of the first element. Simply use the first element, omitting the ByVal keyword. |
|
|
|
|
|
|
|
|
For instance, the Polygon function draws a polygon connecting a series of points with coordinates stored in an array. The following code passes the Points array to the Polygon function by passing the first element Points(1). |
|
|
|
|
|